package com.woniuxy.handler;

import com.woniuxy.exception.CustomException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ExceptionHandler;

public class MyExceptionHandler {
	// 该方法处理controller中所有方法抛出异常，可以指定处理异常的类型
	@ExceptionHandler(Exception.class)
	public String exceptionHandler(Exception e) {
		if (e instanceof CustomException) {
			System.out.println(e.getMessage());
			return "/html/sptupid.html";
		} else if (e instanceof UnauthorizedException) {
			System.out.println("没有权限");
			return "redirect:/error.html";
		}
		return null;
	}

}
